package ru.susu.algebra;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Date;

import ru.susu.algebra.chartable.degree.HooksDegreeCalculator;
import ru.susu.algebra.chartable.degree.IDegreeCalculator;
import ru.susu.algebra.chartable.degree.KnutDegreeCalculator;
import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.partition.PartitionEnumerator;
import ru.susu.algebra.partition.PartitionsFactory;

/**
 * @author akargapolov
 * @since: 06.09.2009
 */
public class DegreesViewer
{
	public static void main(String[] args) throws Exception
	{
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ExecuteResults/Degrees/degrees.txt")));
		IDegreeCalculator hooks = new HooksDegreeCalculator();
		IDegreeCalculator knut = new KnutDegreeCalculator();

		/*
		for (int i = 1; i <= 10; i++)
		{
			out.println(i + ": ");
			Integer length = PartitionEnumerator.getPartitionsNumber(i).intValue();
			for (int j = 0; j < length; j++)
			{
				Partition p = PartitionsFactory.createPartition(j, i);
				p.writeTo(out, 3);
				out.print(" - ");
				out.print(hooks.calculateDegree(p));
				out.print(" - ");
				out.print(knut.calculateDegree(p));
				out.println();
			}
		}*/

		for (int i = 1; i <= 50; i++)
		{
			Integer length = PartitionEnumerator.getPartitionsNumber(i).intValue();
			Date hooksStart = new Date();
			for (int j = 0; j < length; j++)
			{
				Partition p = PartitionsFactory.createPartition(j, i);
				hooks.calculateDegree(p);
			}
			Date hooksEnd = new Date();
			/*
			for (int j = 0; j < length; j++)
			{
				Partition p = PartitionsFactory.createPartition(j, i);
				knut.calculateDegree(p);
			}*/
			Date knutEnd = new Date();
			System.out.println(i + ": Hooks " + (hooksEnd.getTime() - hooksStart.getTime()) + "  Knut "
					+ (knutEnd.getTime() - hooksEnd.getTime()));
		}
		out.close();
	}
}
